<div>
  <form #formRef="ngForm" (ngSubmit)="onSubmit(formRef.value)">
    <fieldset ngModelGroup="login">
      <input type="text"
        name="username"
        [(ngModel)]="username"
        #usernameRef="ngModel"
        required
        minlength="3"
        />
        <div *ngIf="usernameRef.errors?.required">this is required</div>
        <div *ngIf="usernameRef.errors?.minlength">should be at least 3 charactors</div>
      <input type="password"
        name="password"
        [(ngModel)]="password"
        #passwordRef="ngModel"
        required
        />
        <div *ngIf="passwordRef.errors?.required">this is required</div>
      <button (click)="onClick()">Login</button>
      <button type="submit">Submit</button>
    </fieldset>
  </form>
</div>